/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PanelHIstoriaNueva.java
 *
 * Created on 3/02/2012, 01:59:39 PM
 */
package co.edu.eam.clinica.vista.gui.historiaclinica;

import co.edu.eam.clinica.vista.controladores.historiaclinica.controladorHistoriaClinica;
import co.edu.eam.clinica.vista.gui.common.PanelOncologos;
import co.edu.eam.persitencia.entidades.Antecedente;
import co.edu.eam.persitencia.entidades.Ciudad;
import co.edu.eam.persitencia.entidades.DetalleComentarioSistema;
import co.edu.eam.persitencia.entidades.EPS;
import co.edu.eam.persitencia.entidades.ExamenFisico;
import co.edu.eam.persitencia.entidades.HistoriaClinica;
import co.edu.eam.persitencia.entidades.Paciente;
import co.edu.eam.persitencia.entidades.Telefono;
import co.edu.eam.persitencia.enumeraciones.ECEnum;
import co.edu.eam.persitencia.enumeraciones.EstadificacionMEnum;
import co.edu.eam.persitencia.enumeraciones.EstadificacionNEnum;
import co.edu.eam.persitencia.enumeraciones.EstadificacionTEnum;
import co.edu.eam.persitencia.enumeraciones.RevisionSistemaEnum;
import co.edu.eam.persitencia.enumeraciones.SexoEnum;
import co.edu.eam.persitencia.enumeraciones.SistemaEnum;
import co.edu.eam.persitencia.enumeraciones.TipoDocumentoEnum;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Camilo Andres
 */
public class PanelHIstoriaNueva extends PanelOncologos {

    controladorHistoriaClinica controladorH;
    private List<DetalleComentarioSistema> lista;

    /**
     * Creates new form PanelHIstoriaNueva
     */
    public PanelHIstoriaNueva(String documento) {
        initComponents();
        setVisible(true);
        controladorH = new controladorHistoriaClinica();
        cargarEnum();
        lista = new ArrayList<DetalleComentarioSistema>();



        if (documento != null) {
            buscarHistoriaClinica(documento);
        }
    }

    private void buscarHistoriaClinica(String documento) {
        try {
            HistoriaClinica historia = controladorH.buscarHistoriaClinica(documento);

            tfDocumento.setText(historia.getPaciente().getDocumento());
            cbTipoDoc.setSelectedItem(historia.getPaciente().getTipoDocumento());
            tfNombre.setText(historia.getPaciente().getPrimerNombre());
            tfSegundoNOmbre.setText(historia.getPaciente().getSegundoNombre());
            tfApellido.setText(historia.getPaciente().getPrimerApellido());
            tfSegundoApellido.setText(historia.getPaciente().getSegundoApellido());
            tfDireccion.setText(historia.getPaciente().getDireccion());
            cbCiudades.setSelectedItem(historia.getPaciente().getCiudad());
            tfTelefono.setText(telefonos(historia.getPaciente().getTelefonos()));
            tfEmail1.setText(historia.getPaciente().getEmail());
            dcFechaNac.setDate(historia.getPaciente().getFechaNacimiento());
            tfEdad.setText(new Date().getYear() - historia.getPaciente().getFechaNacimiento().getYear() + "");
            cbEPS.setSelectedItem(historia.getPaciente().getEps());
            if (historia.getPaciente().getSexo().equals(SexoEnum.FEMENINO)) {
                rbFemenino.setSelected(true);
            } else {
                rbMAsculino.setSelected(true);
            }

            taAntecedentePersonalHiper.setText(historia.getAntecedentesMedicos().getHipertencion());
            taAntecedentePersonalDiabetes.setText(historia.getAntecedentesMedicos().getDiabetes());
            taAntecedentePersonalCancer.setText(historia.getAntecedentesMedicos().getCancer());
            taAntecedentePersonalAlergias.setText(historia.getAntecedentesMedicos().getAlergia());
            taAntecedentePersonalCirugias.setText(historia.getAntecedentesMedicos().getCirugias());
            taAntecedentePersonalToxicos.setText(historia.getAntecedentesMedicos().getToxicas());
            taAntecedentePersonalTratamiento.setText(historia.getAntecedentesMedicos().getTratamientos());
            taAntecedentePersonalMedicamentos.setText(historia.getAntecedentesMedicos().getMedicamentosActuales());

            taObservacion.setText(historia.getExamenFisico().getObservacion());
            tfPresioArteriar.setText(historia.getExamenFisico().getPresionArterial());
            tfFrecueciaCardiaca.setText(historia.getExamenFisico().getFrecuenciaCardiaca());
            tfFrecuenciaRespiratoria.setText(historia.getExamenFisico().getFrecuenciaRespiratoria());
            tfTalla.setText(historia.getExamenFisico().getTalla() + "");
            TFpESO.setText(historia.getExamenFisico().getPeso() + "");
            tfTemperatura.setText(historia.getExamenFisico().getTemperatura());

            DefaultTableModel modelo = (DefaultTableModel) tablaComentarion.getModel();

            List<DetalleComentarioSistema> detalle = controladorH.listarComentarioSistema(historia);
            modelo.setRowCount(detalle.size());
           
            for (int i = 0; i < detalle.size(); i++) {

                modelo.setValueAt(detalle.get(i).getSistema(), i, 0);
                modelo.setValueAt(detalle.get(i).getComentario(), i, 1);
            }
           

        } catch (Exception ex) {
            Logger.getLogger(PanelHIstoriaNueva.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    private void limpiarCampos() {

        tfDocumento.setText("");
        cbTipoDoc.setSelectedIndex(0);
        tfNombre.setText("");
        tfSegundoNOmbre.setText("");
        tfApellido.setText("");
        tfSegundoApellido.setText("");
        tfDireccion.setText("");
        cbCiudades.setSelectedIndex(0);
        tfTelefono.setText("");
        tfEmail1.setText("");
        dcFechaNac.setDate(null);
        tfEdad.setText("");
        cbEPS.setSelectedIndex(0);
        rbFemenino.setSelected(false);
        rbMAsculino.setSelected(false);

        taAntecedentePersonalHiper.setText("");
        taAntecedentePersonalDiabetes.setText("");
        taAntecedentePersonalCancer.setText("");
        taAntecedentePersonalAlergias.setText("");
        taAntecedentePersonalCirugias.setText("");
        taAntecedentePersonalToxicos.setText("");
        taAntecedentePersonalTratamiento.setText("");
        taAntecedentePersonalMedicamentos.setText("");

        taObservacion.setText("");
        tfPresioArteriar.setText("");
        tfFrecueciaCardiaca.setText("");
        tfFrecuenciaRespiratoria.setText("");
        tfTalla.setText("0");
        TFpESO.setText("0");
        tfTemperatura.setText("");

        cbSistema.setSelectedIndex(0);
        taComentario.setText("");
        
        DefaultTableModel modelo = (DefaultTableModel) tablaComentarion.getModel();
        modelo.setRowCount(0);
        lista.clear();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        tfApellido = new javax.swing.JTextField();
        dcFechaNac = new com.toedter.calendar.JDateChooser();
        tfNombre = new javax.swing.JTextField();
        cbTipoDoc = new javax.swing.JComboBox();
        rbFemenino = new javax.swing.JRadioButton();
        jLabel3 = new javax.swing.JLabel();
        rbMAsculino = new javax.swing.JRadioButton();
        jLabel10 = new javax.swing.JLabel();
        tfDireccion = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        cbEPS = new javax.swing.JComboBox();
        tfDocumento = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        tfSegundoApellido = new javax.swing.JTextField();
        tfSegundoNOmbre = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        tfTelefono = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        cbCiudades = new javax.swing.JComboBox();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        tfEmail1 = new javax.swing.JTextField();
        tfEdad = new javax.swing.JTextField();
        jLabel49 = new javax.swing.JLabel();
        bBuscar = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        tabAntecedentes = new javax.swing.JTabbedPane();
        jPanel7 = new javax.swing.JPanel();
        jLabel28 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        taAntecedentePersonalHiper = new javax.swing.JTextArea();
        jLabel29 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        taAntecedentePersonalDiabetes = new javax.swing.JTextArea();
        jLabel30 = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        taAntecedentePersonalCancer = new javax.swing.JTextArea();
        jLabel31 = new javax.swing.JLabel();
        jScrollPane7 = new javax.swing.JScrollPane();
        taAntecedentePersonalAlergias = new javax.swing.JTextArea();
        jLabel32 = new javax.swing.JLabel();
        jScrollPane8 = new javax.swing.JScrollPane();
        taAntecedentePersonalCirugias = new javax.swing.JTextArea();
        jLabel33 = new javax.swing.JLabel();
        jScrollPane9 = new javax.swing.JScrollPane();
        taAntecedentePersonalToxicos = new javax.swing.JTextArea();
        jLabel34 = new javax.swing.JLabel();
        jScrollPane10 = new javax.swing.JScrollPane();
        taAntecedentePersonalTratamiento = new javax.swing.JTextArea();
        jLabel35 = new javax.swing.JLabel();
        jScrollPane11 = new javax.swing.JScrollPane();
        taAntecedentePersonalMedicamentos = new javax.swing.JTextArea();
        jPanel11 = new javax.swing.JPanel();
        jPanel13 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        taObservacion = new javax.swing.JTextArea();
        jPanel2 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        tfPresioArteriar = new javax.swing.JTextField();
        tfFrecueciaCardiaca = new javax.swing.JTextField();
        tfFrecuenciaRespiratoria = new javax.swing.JTextField();
        tfTalla = new javax.swing.JTextField();
        tfTemperatura = new javax.swing.JTextField();
        jLabel21 = new javax.swing.JLabel();
        TFpESO = new javax.swing.JTextField();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jLabel19 = new javax.swing.JLabel();
        cbSistema = new javax.swing.JComboBox();
        jLabel20 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        taComentario = new javax.swing.JTextArea();
        bAgregar = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        tablaComentarion = new javax.swing.JTable();
        jSeparator1 = new javax.swing.JSeparator();
        bGuardar = new javax.swing.JButton();
        bImprimir = new javax.swing.JButton();

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel12.setText("EPS");

        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel9.setText("Tipo Doc.");

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel2.setText("Primer Apellido");

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel5.setText("Fecha Nacimiento");

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel11.setText("Segundo Nombre");

        tfApellido.setEditable(false);

        tfNombre.setEditable(false);

        buttonGroup1.add(rbFemenino);
        rbFemenino.setText("Femenino");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel3.setText("Direccion");

        buttonGroup1.add(rbMAsculino);
        rbMAsculino.setText("Masculino");

        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel10.setText("Segundo Apellido");

        tfDireccion.setEditable(false);

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel6.setText("Sexo");

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel4.setText("Email");

        tfSegundoApellido.setEditable(false);

        tfSegundoNOmbre.setEditable(false);
        tfSegundoNOmbre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfSegundoNOmbreActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel1.setText("Primer Nombre");

        tfTelefono.setEditable(false);

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel8.setText("Documento");

        jLabel25.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel25.setText("Ciudad");

        jLabel26.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel26.setText("Telefono");

        tfEmail1.setEditable(false);

        tfEdad.setEditable(false);

        jLabel49.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel49.setText("Edad");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel1))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(tfApellido)
                            .addComponent(tfNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel10)
                            .addComponent(jLabel11))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tfSegundoApellido, javax.swing.GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE)
                            .addComponent(tfSegundoNOmbre, javax.swing.GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE)))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel25)
                            .addComponent(jLabel26)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6)
                            .addComponent(jLabel4))
                        .addGap(4, 4, 4)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 83, Short.MAX_VALUE)
                                        .addComponent(rbMAsculino)
                                        .addGap(18, 18, 18)
                                        .addComponent(rbFemenino))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                        .addComponent(dcFechaNac, javax.swing.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jLabel49, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(tfEdad, javax.swing.GroupLayout.DEFAULT_SIZE, 71, Short.MAX_VALUE)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(cbEPS, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(tfEmail1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 572, Short.MAX_VALUE)
                            .addComponent(tfTelefono, javax.swing.GroupLayout.DEFAULT_SIZE, 572, Short.MAX_VALUE)
                            .addComponent(cbCiudades, javax.swing.GroupLayout.PREFERRED_SIZE, 229, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(tfDocumento, javax.swing.GroupLayout.DEFAULT_SIZE, 271, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(cbTipoDoc, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(tfDireccion, javax.swing.GroupLayout.DEFAULT_SIZE, 572, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(tfDocumento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbTipoDoc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(tfNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfSegundoNOmbre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addGap(8, 8, 8)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tfApellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(tfSegundoApellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10))
                        .addGap(2, 2, 2)))
                .addGap(11, 11, 11)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3)
                    .addComponent(tfDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel25)
                    .addComponent(cbCiudades, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(25, 25, 25)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tfTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel26))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tfEmail1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel6))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(cbEPS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(tfEdad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel49))
                            .addComponent(dcFechaNac, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(rbMAsculino)
                            .addComponent(rbFemenino))))
                .addContainerGap())
        );

        bBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/torresquintero/oncologos/medico/imagenes/imagenes/24x24/buscar-buscar-ampliar-icono-4271-32.png"))); // NOI18N
        bBuscar.setText("Buscar");
        bBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bBuscarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(bBuscar))
                .addContainerGap(82, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(bBuscar)
                .addContainerGap(109, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Datos Basicos Paciente", jPanel1);

        jLabel28.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel28.setText("Hipertension");

        taAntecedentePersonalHiper.setColumns(20);
        taAntecedentePersonalHiper.setRows(5);
        jScrollPane3.setViewportView(taAntecedentePersonalHiper);

        jLabel29.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel29.setText("Diabetes");

        taAntecedentePersonalDiabetes.setColumns(20);
        taAntecedentePersonalDiabetes.setRows(5);
        jScrollPane4.setViewportView(taAntecedentePersonalDiabetes);

        jLabel30.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel30.setText("Cancer");

        taAntecedentePersonalCancer.setColumns(20);
        taAntecedentePersonalCancer.setRows(5);
        jScrollPane6.setViewportView(taAntecedentePersonalCancer);

        jLabel31.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel31.setText("Alergias");

        taAntecedentePersonalAlergias.setColumns(20);
        taAntecedentePersonalAlergias.setRows(5);
        jScrollPane7.setViewportView(taAntecedentePersonalAlergias);

        jLabel32.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel32.setText("Cirugias");

        taAntecedentePersonalCirugias.setColumns(20);
        taAntecedentePersonalCirugias.setRows(5);
        jScrollPane8.setViewportView(taAntecedentePersonalCirugias);

        jLabel33.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel33.setText("Toxicos");

        taAntecedentePersonalToxicos.setColumns(20);
        taAntecedentePersonalToxicos.setRows(5);
        jScrollPane9.setViewportView(taAntecedentePersonalToxicos);

        jLabel34.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel34.setText("Tratamientos");

        taAntecedentePersonalTratamiento.setColumns(20);
        taAntecedentePersonalTratamiento.setRows(5);
        jScrollPane10.setViewportView(taAntecedentePersonalTratamiento);

        jLabel35.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel35.setText("Otros");

        taAntecedentePersonalMedicamentos.setColumns(20);
        taAntecedentePersonalMedicamentos.setRows(5);
        jScrollPane11.setViewportView(taAntecedentePersonalMedicamentos);

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(jLabel32)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 43, Short.MAX_VALUE)
                        .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 301, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(jLabel34)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane10, javax.swing.GroupLayout.PREFERRED_SIZE, 301, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel30)
                            .addComponent(jLabel28))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 16, Short.MAX_VALUE)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jScrollPane3)
                            .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 301, Short.MAX_VALUE))))
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel7Layout.createSequentialGroup()
                            .addGap(7, 7, 7)
                            .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                                    .addComponent(jLabel35)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jScrollPane11, javax.swing.GroupLayout.PREFERRED_SIZE, 301, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                                    .addComponent(jLabel33)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 301, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                            .addGap(4, 4, 4)
                            .addComponent(jLabel31)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 301, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                        .addComponent(jLabel29)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 301, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(12, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel28)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel29)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel30)
                    .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel31)
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel33)
                    .addComponent(jLabel32)
                    .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane10, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel34)
                    .addComponent(jScrollPane11, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel35))
                .addContainerGap(28, Short.MAX_VALUE))
        );

        tabAntecedentes.addTab("Personales", jPanel7);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tabAntecedentes))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tabAntecedentes)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Antecedentes", jPanel6);

        jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Observacion Y Conducta", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 12))); // NOI18N

        taObservacion.setColumns(20);
        taObservacion.setRows(5);
        jScrollPane5.setViewportView(taObservacion);

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addGap(49, 49, 49)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 423, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(49, Short.MAX_VALUE))
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(36, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(231, Short.MAX_VALUE))
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(203, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Observacion", jPanel11);

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel7.setText("Presion Arterial");

        jLabel13.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel13.setText("Frecuencia Cardiaca");

        jLabel14.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel14.setText("frecuencia Respiratoria");

        jLabel15.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel15.setText("talla");

        jLabel16.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel16.setText("temperatura");

        tfTalla.setText("0");
        tfTalla.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                tfTallaFocusLost(evt);
            }
        });

        jLabel21.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel21.setText("Peso");

        TFpESO.setText("0");
        TFpESO.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                TFpESOFocusLost(evt);
            }
        });

        jLabel23.setText("kg");

        jLabel24.setText("cm");

        jLabel19.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel19.setText("Sistema");

        cbSistema.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbSistemaActionPerformed(evt);
            }
        });

        jLabel20.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel20.setText("Comentario");

        taComentario.setColumns(20);
        taComentario.setRows(5);
        jScrollPane1.setViewportView(taComentario);

        bAgregar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/torresquintero/oncologos/medico/imagenes/imagenes/24x24/Add.png"))); // NOI18N
        bAgregar.setText("Agregar");
        bAgregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bAgregarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel19)
                    .addComponent(jLabel20))
                .addGap(69, 69, 69)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(cbSistema, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(bAgregar)
                        .addGap(263, 263, 263))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                        .addComponent(jScrollPane1)
                        .addGap(20, 20, 20))))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19)
                    .addComponent(cbSistema, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel20)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
                .addComponent(bAgregar))
        );

        tablaComentarion.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "Sistema", "Comentario"
            }
        ));
        jScrollPane2.setViewportView(tablaComentarion);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 1, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel7)
                            .addComponent(jLabel21)
                            .addComponent(jLabel15)
                            .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel13))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tfTemperatura)
                            .addComponent(TFpESO)
                            .addComponent(tfTalla)
                            .addComponent(tfFrecuenciaRespiratoria)
                            .addComponent(tfFrecueciaCardiaca)
                            .addComponent(tfPresioArteriar, javax.swing.GroupLayout.PREFERRED_SIZE, 306, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel24)
                            .addComponent(jLabel23))
                        .addGap(410, 410, 410))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 517, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel16)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel7)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(tfPresioArteriar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tfFrecueciaCardiaca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel13))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tfFrecuenciaRespiratoria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel14))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tfTalla, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel24)
                            .addComponent(jLabel15))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(TFpESO, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel23)
                            .addComponent(jLabel21))))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel16)
                    .addComponent(tfTemperatura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(23, 23, 23)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(35, 35, 35))
        );

        jTabbedPane1.addTab("Examen Fisico", jPanel2);

        bGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/torresquintero/oncologos/medico/imagenes/imagenes/24x24/guardar-documento-icono-7840-32.png"))); // NOI18N
        bGuardar.setText("Guardar");
        bGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bGuardarActionPerformed(evt);
            }
        });

        bImprimir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/torresquintero/oncologos/medico/imagenes/imagenes/24x24/impresora-icono-7004-32.png"))); // NOI18N
        bImprimir.setText("Imprimir");
        bImprimir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bImprimirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 792, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(bGuardar)
                        .addGap(18, 18, 18)
                        .addComponent(bImprimir))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(23, Short.MAX_VALUE)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 488, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bGuardar)
                    .addComponent(bImprimir)))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void bGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bGuardarActionPerformed

        if (       taAntecedentePersonalHiper.getText().isEmpty()
                || taAntecedentePersonalDiabetes.getText().isEmpty()
                || taAntecedentePersonalCancer.getText().isEmpty()
                || taAntecedentePersonalAlergias.getText().isEmpty()
                || taAntecedentePersonalCirugias.getText().isEmpty()
                || taAntecedentePersonalToxicos.getText().isEmpty()
                || taAntecedentePersonalTratamiento.getText().isEmpty()
                || taAntecedentePersonalMedicamentos.getText().isEmpty()
                || tfPresioArteriar.getText().isEmpty()
                || tfFrecueciaCardiaca.getText().isEmpty()
                || tfFrecuenciaRespiratoria.getText().isEmpty()
                || tfTalla.getText().isEmpty()
                || TFpESO.getText().isEmpty()
                || tfTemperatura.getText().isEmpty()
                                
            ) {
            JOptionPane.showMessageDialog(null,"Diligencie Todos Los Datos");
        }else{            
            try {
                Antecedente antecendete = new Antecedente();
                antecendete.setHipertencion(taAntecedentePersonalHiper.getText());
                antecendete.setDiabetes(taAntecedentePersonalDiabetes.getText());
                antecendete.setCancer(taAntecedentePersonalCancer.getText());
                antecendete.setAlergia(taAntecedentePersonalAlergias.getText());
                antecendete.setCirugias(taAntecedentePersonalCirugias.getText());
                antecendete.setToxicas(taAntecedentePersonalToxicos.getText());
                antecendete.setTratamientos(taAntecedentePersonalTratamiento.getText());
                antecendete.setMedicamentosActuales(taAntecedentePersonalMedicamentos.getText());

                ExamenFisico examen = new ExamenFisico();
                examen.setObservacion(taObservacion.getText());
                examen.setPresionArterial(tfPresioArteriar.getText());
                examen.setFrecuenciaCardiaca(tfFrecueciaCardiaca.getText());
                examen.setFrecuenciaRespiratoria(tfFrecuenciaRespiratoria.getText());
                examen.setTalla(Double.parseDouble(tfTalla.getText()));
                examen.setPeso(Double.parseDouble(TFpESO.getText()));
                examen.setTemperatura(tfTemperatura.getText());

                HistoriaClinica historia = new HistoriaClinica();
                historia.setAntecedentesMedicos(antecendete);
                antecendete.setHistoria(historia);
                historia.setDetalleComentarioSistema(lista);
                for (int i = 0; i < lista.size(); i++) {
                    lista.get(i).setHistoria(historia);
                }
                historia.setExamenFisico(examen);
                examen.setHistoriaClinica(historia);
                historia.setFechaApertura(new Date());
                historia.setPaciente(controladorH.buscarPaciente(tfDocumento.getText()));
                controladorH.crearHistoriaClinica(historia);

                limpiarCampos();
                JOptionPane.showMessageDialog(null, "Historia Clinica Creada");

            } catch (Exception ex) {
                Logger.getLogger(PanelHIstoriaNueva.class.getName()).log(Level.SEVERE, null, ex);
                JOptionPane.showMessageDialog(null, "La historia Clinca Ya existe");
            }
        }
    }//GEN-LAST:event_bGuardarActionPerformed

    private void cargarEnum() {

        SistemaEnum[] sistemaEnum = SistemaEnum.values();
        for (int i = 0; i < sistemaEnum.length; i++) {
            cbSistema.addItem(sistemaEnum[i]);
        }

        TipoDocumentoEnum[] documentoEnum = TipoDocumentoEnum.values();
        for (int i = 0; i < documentoEnum.length; i++) {
            cbTipoDoc.addItem(documentoEnum[i]);
        }
        try {

            List<Ciudad> ciudades = controladorH.listarCiudades();
            for (int j = 0; j < ciudades.size(); j++) {
                cbCiudades.addItem(ciudades.get(j));
            }

            List<EPS> eps = controladorH.listarEps();
            for (int k = 0; k < eps.size(); k++) {
                cbEPS.addItem(eps.get(k));

            }

        } catch (Exception ex) {
            Logger.getLogger(PanelHIstoriaNueva.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    public String telefonos(List<Telefono> tas) {
        String telefonos = "-";
        for (Telefono telefono : tas) {
            telefonos = telefono.getNumero() + telefonos;
        }
        return telefonos;
    }

    private void bImprimirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bImprimirActionPerformed
    }//GEN-LAST:event_bImprimirActionPerformed

    private void bAgregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bAgregarActionPerformed



        DetalleComentarioSistema detalle = new DetalleComentarioSistema();
        detalle.setComentario(taComentario.getText());
        detalle.setSistema((SistemaEnum) cbSistema.getSelectedItem());
        lista.add(detalle);

        DefaultTableModel modelo = (DefaultTableModel) tablaComentarion.getModel();

        modelo.setRowCount(lista.size());

        for (int i = 0; i < lista.size(); i++) {
            DetalleComentarioSistema detalle2 = lista.get(i);
            modelo.setValueAt(detalle2.getSistema(), i, 0);
            modelo.setValueAt(detalle2.getComentario(), i, 1);
        }
        taComentario.setText("");
    }//GEN-LAST:event_bAgregarActionPerformed

    private void cbSistemaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSistemaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cbSistemaActionPerformed

    private void TFpESOFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_TFpESOFocusLost
    }//GEN-LAST:event_TFpESOFocusLost

    private void tfTallaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tfTallaFocusLost
        // TODO add your handling code here:
    }//GEN-LAST:event_tfTallaFocusLost

    private void bBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bBuscarActionPerformed
        try {
            String documentoPac = tfDocumento.getText();

            Paciente paci = controladorH.buscarPaciente(documentoPac);

            cbTipoDoc.setSelectedItem(paci.getTipoDocumento());
            tfNombre.setText(paci.getPrimerNombre());
            tfSegundoNOmbre.setText(paci.getSegundoNombre());
            tfApellido.setText(paci.getPrimerApellido());
            tfSegundoApellido.setText(paci.getSegundoApellido());
            tfDireccion.setText(paci.getDireccion());
            cbCiudades.setSelectedItem(paci.getCiudad());
            tfTelefono.setText(telefonos(paci.getTelefonos()));
            tfEmail1.setText(paci.getEmail());
            dcFechaNac.setDate(paci.getFechaNacimiento());
            tfEdad.setText(new Date().getYear() - paci.getFechaNacimiento().getYear() + "");
            cbEPS.setSelectedItem(paci.getEps());

            if (paci.getSexo().equals(SexoEnum.FEMENINO)) {
                rbFemenino.setSelected(true);
            } else {
                rbMAsculino.setSelected(true);
            }

        } catch (Exception ex) {
            Logger.getLogger(PanelHIstoriaNueva.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_bBuscarActionPerformed

    private void tfSegundoNOmbreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfSegundoNOmbreActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfSegundoNOmbreActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField TFpESO;
    private javax.swing.JButton bAgregar;
    private javax.swing.JButton bBuscar;
    private javax.swing.JButton bGuardar;
    private javax.swing.JButton bImprimir;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JComboBox cbCiudades;
    private javax.swing.JComboBox cbEPS;
    private javax.swing.JComboBox cbSistema;
    private javax.swing.JComboBox cbTipoDoc;
    private com.toedter.calendar.JDateChooser dcFechaNac;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel35;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel49;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane10;
    private javax.swing.JScrollPane jScrollPane11;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JRadioButton rbFemenino;
    private javax.swing.JRadioButton rbMAsculino;
    private javax.swing.JTextArea taAntecedentePersonalAlergias;
    private javax.swing.JTextArea taAntecedentePersonalCancer;
    private javax.swing.JTextArea taAntecedentePersonalCirugias;
    private javax.swing.JTextArea taAntecedentePersonalDiabetes;
    private javax.swing.JTextArea taAntecedentePersonalHiper;
    private javax.swing.JTextArea taAntecedentePersonalMedicamentos;
    private javax.swing.JTextArea taAntecedentePersonalToxicos;
    private javax.swing.JTextArea taAntecedentePersonalTratamiento;
    private javax.swing.JTextArea taComentario;
    private javax.swing.JTextArea taObservacion;
    private javax.swing.JTabbedPane tabAntecedentes;
    private javax.swing.JTable tablaComentarion;
    private javax.swing.JTextField tfApellido;
    private javax.swing.JTextField tfDireccion;
    private javax.swing.JTextField tfDocumento;
    private javax.swing.JTextField tfEdad;
    private javax.swing.JTextField tfEmail1;
    private javax.swing.JTextField tfFrecueciaCardiaca;
    private javax.swing.JTextField tfFrecuenciaRespiratoria;
    private javax.swing.JTextField tfNombre;
    private javax.swing.JTextField tfPresioArteriar;
    private javax.swing.JTextField tfSegundoApellido;
    private javax.swing.JTextField tfSegundoNOmbre;
    private javax.swing.JTextField tfTalla;
    private javax.swing.JTextField tfTelefono;
    private javax.swing.JTextField tfTemperatura;
    // End of variables declaration//GEN-END:variables
}
